﻿
/////////////////////////////////////////////////////////////////
//File: UserCollection.cs
//Description: 
//Copyright© 2012 Moliu
//History:
//  2012-3-26 18:11:20    moliu    Original Version
/////////////////////////////////////////////////////////////////
using System;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Data.SqlTypes;
using IBatisNet.DataMapper;
using IBatisNet.DataMapper.Configuration;
using MAF.Common;
using MAF.CRUD;
using MAF.Authentication.Domain;

namespace MAF.Authentication.Database.Persistence
{
    public class UserCollection : DatabaseCRUD<UserInfo>
    {
        protected override string _MapAdd { get { return "User.Add"; } }
        protected override string _MapUpdate { get { return "User.Update"; } }
        protected override string _MapDelete { get { return "User.Delete"; } }
        protected override string _MapSearch { get { return "User.Search"; } }
        protected override string _MapCount { get { return "User.Count"; } }

        private string _TABLE = "";
        protected override string _Table
        {
            get { return _TABLE; }
            set { _TABLE = value; }
        }

        #region 构造方法

        public UserCollection(string configFile, string tableName)
            : base(configFile) 
        {
            _Table = tableName;
        }

        #endregion

        #region Private Method

        private UserInfo Check(UserInfo info)
        {
            if (DateTime.MinValue == info.CreatedOn)
                info.CreatedOn = DateTime.Parse(SqlDateTime.MinValue.ToString());
            if (DateTime.MinValue == info.ModifiedOn)
                info.ModifiedOn = DateTime.Parse(SqlDateTime.MinValue.ToString());

            return info;
        }

        #endregion
    }
}